package cn.tedu.charging.order.config;

import cn.tedu.charging.common.utils.SnowflakeIdGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SnowFlakeConfiguration {
    //读取当前程序运行所在的数据中心id 读取所在机器服务器id
    private Integer centerId=1;
    private Integer machineId=1;

    //通过注入的2个环境值生成初始化雪花工具
    @Bean
    public SnowflakeIdGenerator idGenerator() {
        return new SnowflakeIdGenerator(centerId, machineId);
    }
}
